﻿@{
    ViewBag.Title = "DictionaryImport";
}
@section head
{
<script type="text/javascript" src="@Url.Content("~/ScriptPlugin/webuploader/webuploader.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/KingsSharp.Uploader.js")"></script>
<link href="@Url.Content("~/ScriptPlugin/easyui/themes/gray/easyui.css")" rel="stylesheet" />
<link href="@Url.Content("~/ScriptPlugin/easyui/themes/icon.css")" rel="stylesheet" />
<script type="text/javascript" src="@Url.Content("~/ScriptPlugin/easyui/jquery.easyui.min.js")"></script>
<script type="text/javascript" src="@Url.Content("~/ScriptPlugin/easyui/locale/easyui-lang-zh_CN.js")"></script>
}
<form>
    <input type="hidden" name="Path" id="Path" />
    <div id="grid" style="height:100%">
        <div id="toolpannel">
            <div class="content-pannel-buttons">
                <a href="@Url.Content("~/Sys/Dictionary/DictionaryTemplate")"><b class="p-icon-excle">模版</b></a>
                <a onclick="" id="picker"><b class="p-icon-upload">导入</b></a>
            </div>
        </div>
    </div>
</form>
@section foot
{
    <script type="text/javascript">
    var uploader = new KingsSharp.Uploader().createExcle({
        swf: '@Url.Content("~/ScriptPlugin/webuploader/Uploader.swf")',
        server: '@Url.Content("~/Sys/Dictionary/UploaderProcess")',
            pick: '#picker',
            resize: false,
            auto:true
         }, {
             uploadSuccess: function (file, response)
             {
                 if (response.Filish)
                 {
                     $("#Path").val(response.Path);
                     loadData(response.obj);
                 }
             }
         });
        function loadData(data)
        {
            var loadFilter = function (data) {
                if (data.Total != undefined) {
                    data.total = data.Total;
                    delete data.Total;
                }
                if (data.Rows != undefined) {
                    data.rows = data.Rows;
                    delete data.Rows;
                }
                return data;
            };
            var columns11 = [[
                {field: "Name", title: "字典名称", width: 180},
                { field: "Description", title: "字典说明" },
                { field: "Order", title: "排序", width: 40 },
                { field: "PName", title: "上级目录", width: 60 }
            ]];
            var grid = $("#grid-bundles").datagrid({
                columns:columns11,
                fit: true,
                fitColumns: false,
                toolbar: "#toolpannel",
                loadMsg: "正在拼命加载，请稍候",
                striped: true,
                nowrap: false,
                loadFilter: loadFilter
            });
            grid.datagrid('loadData', data);
        }
        loadData(null);
        function start() {
            uploader.upload();
        }
        function SaveData()
        {
            var item = $('#grid-bundles').datagrid('getRows');
            if (KingsSharp.Confirm("是否确认导入" + item .length+ "条数据？", function () {
                KingsSharp.AjaxJson("@Url.Content("~/Sys/Dictionary/DictionaryImport")", { Path: $("#Path").val() }, function (result) {
                    parent.K.layer.callback(index, result);
                    parent.K.layer.close(index);
                });
            }));
        }
    </script>
}